<template>
  <div class="time_deposit_confirm">
    <div class="payment_box">
      <van-cell title="付款账号" :value="form.payerAcNo" />
      <van-cell title="转账金额" >
        <template #default>{{form.amount | currency}}</template>
      </van-cell>
      <van-cell title="" class="balance">
        <template #default>
          （{{ form.amount | convertToChinaNum}}）
        </template>
      </van-cell>
    </div>
    <div class="investment_box">
      <van-cell title="存期" >
        <template #default>
          {{deposits[form.deposit]}}
        </template>
      </van-cell>
      <van-cell title="利率" :value="form.rate" />
      <van-cell title="到期自动转存" >
        <template #default>
          {{automaticItems[form.autoSaveType]}}
        </template>
      </van-cell>
      <van-cell title="备注" :value="form.remark" />
    </div>
    <div class="next_box">
      <van-button color="linear-gradient(to right, #20B1F2, #1393D3)"
                  type="info" @click="buyRegular" block>提交</van-button>
    </div>
  </div>
</template>

<script>
import { currentToRegular } from '@/libs/api';
import Constants from '@/libs/constant';

export default {
  data() {
    return {
      form: this.$store.state.formData,
      automaticItems: Constants.automaticItems,
      deposits: Constants.deposits
    };
  },
  methods: {
    next() {
      console.log(1);
    },
    buyRegular() {
      currentToRegular({
        ...this.form,
        hostNo: this.$store.state.loginUser.cino,
        cstNo: this.$store.state.loginUser.cichno,
        operNo: this.$store.state.loginUser.userId,
        menuId: 204
      }).then((res) => {
        if (res.retCode === 'CIP0000000') {
          this.$toast({ position: 'bottom', message: '购买成功!' });
          setTimeout(() => {
            this.$router.go(-2);
          }, 500);
        }
      });
    }
  }
};
</script>

<style lang="less">
.time_deposit_confirm {
  height: 100%;
  background-color: #EFEFEF;
  .payment_box {
    padding-top: 1vh;
  }
  .investment_box {
    padding-top: 1vh;
  }
  .next_box{
    padding: 1.2rem 0.8rem;
  }
}
</style>
